#include <bits/stdc++.h>
using namespace std;

int arr[5000000] = {0};

int main() {
	int n = 0, count = 0;
	cin >> n >> count;
	for (int i = 0; i < n; ++i) {
		cin >> arr[i];
	}
	sort(arr, arr + n);
	cout << arr[count];
	return 0;
}